package server.demo.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import server.demo.entity.Payment;

import java.util.List;

@Repository
public interface PaymentRepository extends JpaRepository<Payment, Long> {
    
    List<Payment> findByOrderId(Long orderId);
    
    List<Payment> findByOrderIdAndPaymentStatus(Long orderId, Payment.PaymentStatus paymentStatus);
    
    List<Payment> findByOrderIdAndPaymentType(Long orderId, Payment.PaymentType paymentType);
    
    @Query("SELECT p FROM Payment p WHERE p.order.user.id = ?1 ORDER BY p.createdAt DESC")
    List<Payment> findByOrderUserIdOrderByCreatedAtDesc(Long userId);
}